Using the AT Command
You can also use the AT
command to schedule tasks. By default, the AT command is run using the
LocalSystem account, which requires administrative privileges. To
specify another account as the user of the AT command, follow these
steps:
1. | Open Control Panel and double-click Scheduled Tasks.
| 2. | In the Scheduled Tasks window, open the Advanced menu and then choose AT Service Account.
| 3. | Click This Account, and specify a particular user and password. Click OK.
|
The command structure for the AT command is as follows:
AT [\\computername] [id] [[/delete]| /delete [/yes]] AT [\\computername] time [/interactive] [/every:date[,...] | /next:date[,...]] command
The following parameters can
be used with the AT command. Used without parameters, the AT command
returns a list of scheduled commands.
\\computername Specifies a remote computer. Without this parameter, the local computer is assumed. id Indicates the identification number, if one is assigned. /delete Cancels a scheduled command. If no identification number is specified, all scheduled commands on the computer will be canceled. /yes Forces a yes answer to all system queries when canceling all commands. time Specifies when the command is to run, expressed as hours:minutes in 24-hour notation. /interactive Allows the task to interact with the desktop of the user logged on at the time the job is run. /every:date[,...]
Runs the command on the date specified. The date can be specified as
one or more days of the week (M, T, W, Th, F, S, Su) or as one or more
days of the month (numbers 1 through 31). Separate multiple dates with
commas. If this parameter is omitted, the current day of the month is
assumed. /next:date[,...]
Runs the command on the next occurrence of the specified day. If this
parameter is omitted, the current day of the month is assumed. command Indicates the program, batch file, or command to be run. If a path is required, use the Uniform Naming Convention (UNC) path.
Here are some important facts to keep in mind about the AT command:
The AT command
doesn’t automatically load Cmd, the command interpreter. Therefore, if
the command parameter doesn’t point to an executable file, you must
explicitly specify Cmd, followed by the /c switch, at the beginning of
the command.
Using cron
If you are running Windows
Server 2003 R2, you have one other scheduler available to you, the UNIX
cron daemon that is included as part of the Subsystem for UNIX
Applications (SUA). This is a full implementation of cron that behaves
exactly as any UNIX system administrator would expect.
Windows Server 2003
includes a number of improvements in command-line functions, such as
file and folder autocompletion. Windows Server 2003 SP1 and later has
the feature turned on by default, with the Tab key as the autocompletion
key.
To turn this feature on in
earlier versions of Windows Server 2003, open a command-line window and
type cmd /f:on. Now you can avoid typing long file or folder names at
the command line. For example, to navigate into the Program Files folder
from the root of the system drive (typically C), you’d type c:\cd p and then press Ctrl+D. The command expands immediately to c:\cd “Program Files”. Press Enter to invoke that path.
Autocompletion also works
with files. Let’s say you’re in C:\Program Files\Windows Media Player
and you would like to execute Mplayer.exe. At the command line, type mp
and then press the Tab key. The path expands to include Mplayer.exe.
Press Enter to actually execute the file.
Another useful
autocompletion method is the use of wildcards. You can use multiple
wildcards in a single command line, so you could type cd /d pro*86)\com* to change to the C:\Program Files (x86)\Common Files directory on an x64 Edition server.
Another command-line
feature re-creates the functions of DOSKEY. Press the up and down arrows
on the keyboard to navigate through recently used commands. Press F7
for a GUI-based display of recently used commands from which you can
choose, also using the up and down arrows. Press Enter when you’ve
arrived at the command you want to reuse.
For complete documentation on the command prompt, open a command window and type help cmd.
|
Commands
scheduled using AT run as background processes, so there is no
displayed output. To redirect output to a file, use the redirection
symbol (>). The redirection symbol must be preceded by the escape
symbol (^), so a sample command would be at retrieve.bat ^>c:\daylog.txt. If
you have to use a drive letter to connect to a shared directory,
include an AT command to disconnect the drive when the task is
completed. Otherwise, the assigned drive letter will be neither
available nor seen at the command prompt. Note
You can switch back
and forth between the AT command and Task Scheduler, although there are
some limitations. For example, if you schedule a task using AT and later
modify that same task using Task Scheduler, the task is then “owned” by
Task Scheduler and you can no longer access it using AT.
|